package _16String支持正则的方法;

import java.util.Arrays;

public class Demo {
    public static void main(String[] args) {
        //切割 split
        String s = "2012-12-12";
        String[] array = s.split("-");
        System.out.println(Arrays.toString(array));

        String word = "hello   world     java";
        String[] arr2 = word.split(" +"); //空格可能有一到多个
        System.out.println(Arrays.toString(arr2));

        //全局替换 replaceAll
        String word1 = "hello   world     java";
        //把多个空格换成一个空格
        //replaceAll("正则表达式","新的内容");
        String word2 = word1.replaceAll(" +", " ");
        System.out.println(word2);

        String s1 = s.replaceAll("-", "/");
        System.out.println(s1);
    }
}
